Conversation
kivkiv12345
left a comment
There was a problem hiding this comment.
As I understand it, reference counting on Python globals is not strictly required, but it still seems preferred as indicated by the macro Py_RETURN_NONE, which will "return Py_NewRef(Py_None)".
Whenever an exposed function returns an object to Python, it is expected to be a new reference. Python therefore decrements the reference count of the returned object, when it falls out of scope.
Suffice to say, not incrementing the reference count when returning, steals a reference. This will eventually cause the object to be deallocated while it is still in use, causing a segmentation fault.
Fortunately, I don't think this is the case with builtin globals (such as None), which Python knows to never deallocate. Nevertheless, it doesn't hurt to reference count correctly.
Occurrences of "return Py_None" (that return to Python) therefore ought to be replaced with either "Py_RETURN_NONE" or "return Py_NewRef(Py_None)".
|
There are also some places in victoria_metrics.c where we don't check the return value of strdup(), which will be NULL when we run out of memory. |
|
Remind me to not forget about this PR. |
Please check if this is okay.
Currently seems able to start and stop thread.
username, password, use_ssl, port, skip_verify and verbose are optional. The latter 4 will default to 0.